package com.college.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.college.dao.StudentRegistrationDao;
import com.college.domain.Student;

public class StudentRegistrationDaoImpl implements StudentRegistrationDao{
	
	private HibernateTemplate hibernateTemplate;
	   
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}
	
	public Boolean studentPersistanceDao(Student student){
		
		
		List<Student> userList=hibernateTemplate.find("FROM Student student WHERE student.registrationNo ="+student.getRegistrationNo());
		if(userList==null){
			hibernateTemplate.saveOrUpdate(student);
			return true;
		}else{
			return false;
		}
		
		
		
	}

}
